package main

import (
	"fmt"
	"strings"
)

func lengthLongestPath(input string) int {
	m := map[int]string{
		0: "",
	}
	max := 0
	for i := 0; i < len(input); {
		k := i
		tLen := 0
		for ; k < len(input); k++ {
			if input[k] == '\n' {
				break
			}

			if input[k] == '\t' {
				tLen++
			}
		}

		if strings.Contains(input[i:k], ".") {
			if len(m[tLen-1]+input[i+tLen:k]) > max {
				max = len(m[tLen-1] + input[i+tLen:k])
				fmt.Println(m[tLen-1] + input[i+tLen:k])
			}
		} else {
			m[tLen] = m[tLen-1] + input[i+tLen:k] + "/"
		}

		i = k + 1
	}

	return max
}

func main() {
	fmt.Println(lengthLongestPath("dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext"))

}
